<?php
class App_Tpl_Form_Field_Select extends App_Tpl_Form_Field{

	public function PreparePost($fieldPostData, $params)
	{
		$fieldPostData = (string)$fieldPostData;
		
		$realData = null;
		
		$values = $params['values'];
		if (!is_array($values) || !sizeof($values)) return $fieldPostData;
		
		foreach ($values as $value => $data)
		{
			if ((is_array($data) && array_key_exists($fieldPostData, $data))
				|| ($value == $fieldPostData))
			{
				$realData = $fieldPostData;
				break;
			}
		}
		
		return $realData;
	}

	public function PrepareOut($fieldData, $params)
	{
		return (string)$fieldData;
	}
	
    protected function RenderField()
    {
    	return $this->render('form/field/_select.phtml');
    }
	
}